home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / music / 188 / c / doit.c < prev    next >
C/C++ Source or Header  |  1987-10-14  |  911b  |  48 lines

  1. #include <stdio.h>
  2. #include "qsed.h"
  3. static int lines=0;
  4. static char work[BUFSIZ];
  5.  
  6. void doit(cmd,f)
  7. COMMAND *cmd;
  8. FILE *f;
  9. {
  10.     int fix_lines;
  11. #ifdef VERBOSE
  12.     fprintf(stderr,"starting line: %u\nending line %u\n command type %u\n",
  13.         cmd->start,cmd->end,cmd->type);
  14. #endif
  15.     fix_lines=0;
  16.     if(cmd->type==COM_ERR)
  17.         fatal("error in command file");
  18.     while(lines < cmd->start)
  19.     {
  20.         fgets(work,BUFSIZ-1,stdin);
  21.         if(feof(stdin)) fatal("eof of input file!");
  22.         fputs(work,stdout);
  23.         lines++;
  24.     }
  25.     if((cmd->type & COM_ADD)==COM_ADD)
  26.     {
  27.         for(;;)
  28.         {
  29.             fgets(work,BUFSIZ-1,f);
  30.             if(*work=='.') break;
  31.             fputs(work,stdout);
  32.             fix_lines++;
  33.         }
  34.         
  35.     }
  36.     if((cmd->type & COM_DEL)==COM_DEL)
  37.     {
  38.         while(lines<cmd->end)
  39.         {
  40.             fgets(work,BUFSIZ-1,stdin);
  41.             if(feof(stdin)) fatal("eof of input file");
  42.             lines++;
  43.         }
  44.         fix_lines -=(cmd->end-cmd->start);
  45.     }
  46.     lines += fix_lines;
  47. }
  48.